package com.hucheng.activity.vo;

import com.hucheng.activity.entity.UserPointExpiredDetailsDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-10
 * @Description: 返回界面数据
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserPointExpiredDetailsVO implements Serializable {
    private Integer userPointExpiredDetailsId;
    private Integer point;
    private Integer userId;
    private Integer pointType;
    private String source;
    private String expiredTime;
    private Integer isDel;
    private String dateCreated;
    private String dateUpdated;

    public static UserPointExpiredDetailsVO buildUserPointExpiredDetailsVO(final UserPointExpiredDetailsDO userPointExpiredDetailsDO) {
        if (userPointExpiredDetailsDO == null) {
            return null;
        }
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new UserPointExpiredDetailsVO(
                userPointExpiredDetailsDO.getUserPointExpiredDetailsId(),
                userPointExpiredDetailsDO.getPoint(),
                userPointExpiredDetailsDO.getUserId(),
                userPointExpiredDetailsDO.getPointType(),
                userPointExpiredDetailsDO.getSource(),
                sdf.format(userPointExpiredDetailsDO.getExpiredTime()),
                userPointExpiredDetailsDO.getIsDel(),
                dateTimeFormatter.format(userPointExpiredDetailsDO.getDateCreated().toLocalDateTime()),
                dateTimeFormatter.format(userPointExpiredDetailsDO.getDateUpdated().toLocalDateTime()));
    }
}
